#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <iostream>
#include <linux/sched.h>
void* pthreadFunc(void* argv){
    int* pa = (int*)argv;
    for(int j = 0;j < 100;j++){
        // sleep(1);
        printf("i am pthread the a now is %d\n",*pa);
        (*pa)++;
    }
    printf("pthread:%p\n",pa);
    // return NULL;
    return (void*)100;
}

int main(){
    int a = 0;
    pthread_t tid;
    if(pthread_create(&tid,NULL,pthreadFunc,&a) != 0){
        perror("pthread_create");
        exit(EXIT_FAILURE);
    }
    for(int i = 0;i < 100;i++){
        // sleep(1);
        printf("i am main the a now is %d\n",a);
        a++;
    }
    printf("main   :%p\n",&a);
    printf("tid:%ld\n",tid);
    // struct task_struct* id = (struct task_struct*)tid;
    printf("pthread descripor:0x%lx\n",tid);
    void* pthread_return = NULL;
    pthread_join(tid,&pthread_return);
    printf("%ld\n",(long int)pthread_return);
    return 0;
}